<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>预览</title>
    <script src="/easypoijs/jquery-1.9.1.min.js"></script>
    <script src="/easypoijs/polyfill.min.js"></script>
    <script src="/easypoijs/web-office-sdk-v1.1.2.umd.js"></script>
    <script>
        $(document).ready(function () {
            let filePath = getUrlParam('filePath');
            $.get('v1/3rd/file/getViewUrl?filePath=' + filePath, function (data) {
                let easyWps = WebOfficeSDK.config({
                    mode: 'simple',
                    url: data.wpsUrl, // 如果需要通过js-sdk传递token方式鉴权，则需要包含_w_tokentype=1参数
                    //mount: document.querySelector('#easypoi-wps-mount')
                })
                easyWps.setToken({token: data.token})
                // 如果需要对iframe进行特殊的处理，可以通过以下方式拿到iframe的dom对象
                //console.log(easyWps.iframe)
                // 打开文档结果
                easyWps.on('fileOpen', function (data) {
                    console.log(data.success)
                })
            })
        });

        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return decodeURI(r[2]);
            return null; //返回参数值
        }
    </script>
</head>
<body>
</body>
</html>